﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace V2
{
    public class ColumnReference
    {
        private String m_Table;
        private String m_Field;
        private Type m_Type;
        public ColumnReference(string table, string field, Type type)
        {
            m_Table = table;
            m_Field = field;
            m_Type = type;
        }

        public string Field { get { return m_Field; } }
        public Type Type { get { return m_Type; } }
        public string Table { get { return m_Table; } }
    }

    public class ColumnSet {
        protected List<ColumnReference> m_Columns;
        protected List<bool> m_IsNullAllowed;
        protected bool[] m_Mask;

        public virtual Values GetSubset( Values input ) { throw new NotImplementedException(); }
        public MaskedValues GetMaskedValues( Values input ) { return input.GetMaskedValues( m_Mask, input ); }
    }

    public class AdhocColumnSet  : ColumnSet {
        public int[] m_RelevantColumns;

        public AdhocColumnSet( Values values_example, params int[] relevant_columns ) {
            m_Mask = new bool[ values_example.FieldCount ];
            for (int i = 0; i < relevant_columns.Length; i++ ) {
                m_Mask[ relevant_columns[ i ] ] = true;
            }
            m_RelevantColumns = relevant_columns;
        }

        public override Values GetSubset(Values input) {
            IComparable[] fields = new IComparable[input.FieldCount];
            for( int i=0 ; i < m_RelevantColumns.Length ; i++ ) {
                fields[m_RelevantColumns[i]] = ( IComparable ) input.GetFieldValue(m_RelevantColumns[i]);
            }
            return new AdhocValues( fields );
        }
    }
}
